package com.vanke.agent.common.thrift;

import java.io.IOException;

import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TTransportException;

import com.vanke.agent.common.thrift.SerialServer.Client;

public class UniteSericeClient extends Client {
	
	private TTransport transport;
    
    public UniteSericeClient(TProtocol prot,int port, TTransport ftransport) throws TTransportException {
        super(prot);
        this.transport  = ftransport;
    }
    public static UniteSericeClient getClient(String ip,int port) throws TTransportException, IOException{
        TSocket transport = new TSocket(ip,port);
        
        TProtocol protocol = new TBinaryProtocol(transport);
        transport.open();
        UniteSericeClient client = new UniteSericeClient(protocol, port,transport) ;
        return client;
    }
    
    public void close(){
        this.transport.close();
    }
    
    public static void main(String[] args) throws IOException, TException {
    	UniteSericeClient client = getClient("10.0.40.246", 5678);
         
        System.out.println("sequence:" + client.getNextSerial("01") );         
    }
}
